<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class user_list extends Page
{
       public $JTJavaScript2 = null;
       public $JTJavaScript1 = null;
       public $imgAdd = null;
       public $Image1 = null;
       public $JTUserList = null;
       public $JTSiteTheme1 = null;
       function user_listCreate($sender, $params)
       {
       $this->imgAdd->setLink('user_create.php');


       }

       function imgAddJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new.png"
       <?php

       }

       function imgAddJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new_blue.png"
       <?php

       }

       function JTUserListShow($sender, $params)
       {
       $array = array();
       $company_id = $_SESSION['company_id'];
       $query_users = "SELECT * FROM accounts_tbl WHERE company_id='".$company_id."'";
       $result_users = mysql_query($query_users) or die("SELECT USERS ".mysql_error());
       while($row_users = mysql_fetch_array($result_users))
       {
        $user_id = $row_users['auto_id'];
        $access_id = $row_users['access_level_id'];

        $created_by = $row_users['created_by'];
        //$username = "<a href='user_edit.php?user_id=".$user_id."'>".$row_users['username']."</a>";
        $admin = $row_users['admin'];
        $tools = "<img onclick=change_pw('".$user_id."'); src='image/change_pw.png' title='Change Password' style='cursor:pointer'>
        <img onclick=js_deleteUser('".$user_id."'); src='image/delete.png' title='delete' style='cursor:pointer'>";

        $query_access = "SELECT * FROM accounts_access_level WHERE id='".$access_id."'";
        $result_access = mysql_query($query_access) or die("SELECT ACCESS ".mysql_error());
        $row_access = mysql_fetch_array($result_access);
        //<img onclick=pop_report('".$vehicle_id."'); src='image/reports.png' title='generate reports'>
        //<a href='user_change_pw.php?user=".$user_id."'>

        if($admin=='1')
        $admin = "Administrator";
        if($admin=='0')
        $admin = "User";

        if($created_by=='admin_amps_admin')
        {
        $access_level = 'Admin';
        }

        if($created_by!='admin_amps_admin')
        {
        $access_level = $row_access['account_level'];
        }

        $array[] = array("Username"=>$row_users['username'],
        "Access Level"=>$access_level,
        "Tools"=>$tools);
       }
       $this->JTUserList->setCellData($array);

       }

}

global $application;

global $user_list;

//Creates the form
$user_list=new user_list($application);

//Read from resource file
$user_list->loadResource(__FILE__);

//Shows the form
$user_list->show();

?>